package com.postracker.postracker.util;

public final class ArrayUtils {

	private static final ArrayUtils INSTANCE = new ArrayUtils();

	private static final String COMMA_SEPARATOR = ", ";

	private ArrayUtils() {
		// Nothing to do, just limiting the scope
	}

	public static ArrayUtils getInstance() {
		return INSTANCE;
	}

	public StringBuilder addCommaSeparatedValues(String[] values,
			StringBuilder sb) {
		for (String value : values) {
			sb.append(value).append(COMMA_SEPARATOR);
		}
		return removeLastOcurrence(sb);
	}

	private StringBuilder removeLastOcurrence(StringBuilder sb) {
		sb.delete(sb.lastIndexOf(COMMA_SEPARATOR), sb.length());
		return sb;
	}

}
